package com.fastCms.business.mall.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fastCms.business.mall.pojo.entity.Product;
import com.fastCms.business.mall.pojo.po.AppProductRandomRecommendPO;
import com.fastCms.business.mall.pojo.po.AppQueryProductPO;
import com.fastCms.business.mall.pojo.po.ProductQueryPO;
import com.fastCms.business.mall.pojo.po.ProductQuerySelectorPO;
import com.fastCms.business.mall.pojo.vo.AppProductListVO;
import com.fastCms.business.mall.pojo.vo.ProductDataStatisticsVO;
import com.fastCms.business.mall.pojo.vo.ProductSelectorVO;
import com.fastCms.business.mall.pojo.vo.ProductVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 产品主表 Mapper 接口
 * </p>
 *
 * @author lsquan
 * @since 2019-04-09
 */
@Repository
public interface ProductMapper extends BaseMapper<Product> {

    List<ProductVO> findProduct(ProductQueryPO productQueryPO);

    List<ProductSelectorVO> productSelector(ProductQuerySelectorPO queryProductSelectorPO);

    //app的商品列表
    List<AppProductListVO> findAppProductList(AppQueryProductPO appQueryProductPO);

    // 随机推荐商品
    List<AppProductListVO> findAppRandomProducts(AppProductRandomRecommendPO appProductRandomRecommendPO);

    // 商品数据统计
    ProductDataStatisticsVO findDataStatistics(@Param("organizeCode") String organizeCode);

    // 扣减商品库存
    boolean decrStock(@Param("productId") String productId, @Param("decrStock") Integer decrStock);

    // 查询品牌下的商品ID
    List<String> findProductIdsByBrandId(@Param("brandId") String brandId);

    // 查询商品中在这些品牌下的商品
    List<String> findProductIdsInBrand(@Param("brandIds") List<String> brandIds, @Param("productIds") List<String> productIds);
}
